package springMVC.getParams.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author quan
 * @Description 获取Cookie
 * @Date 2023/7/22 10:42
 */


@RestController
@RequestMapping("/web")
public class Demo8_GetCookie {
    //原始方式，request.getCookies()直接获取
//    @RequestMapping("/get8")
//    public String get8(HttpServletRequest request){
//        request.getCookies();
//        return "aaa";
//    }

    //默认要传参。否则自己设置required=false
//    @RequestMapping("/get8")
//    public String get8(@CookieValue String name){
//        return "name"+name;
//    }

    //cookie重命名
    @RequestMapping("/get8")
    public String get8(@CookieValue(name = "name") String name888){
        return "name"+name888;
    }
}
